package controllers

import (
	"photo_credit/constant"
	"photo_credit/models"
)

type PageController struct {
	MainController
}

// Index 主页跳转
func (c *PageController) Index() {
	user := c.GetSession(constant.USER_SESSION)
	c.Data[constant.USER_SESSION] = user
	c.TplName = "index.html"
}

// Login 登录页面跳转
func (c *PageController) Login() {
	c.TplName = "login.html"
}

// Register 登录页面跳转
func (c *PageController) Register() {
	c.TplName = "register.html"
}

// ImageAuthor 图片认证页面跳转
func (c *PageController) ImageAuthor() {
	//检查用户登录是否已经实名认证
	user := c.GetSession(constant.USER_SESSION)
	loginUser := user.(models.User)
	models.SelectUserById(&loginUser)
	//未实名，去上传身份证
	if loginUser.IdentityCard == "" {
		c.TplName = "userSFZAuthor.html"
		return
	}

	//已经实名就跳转到认证作品页面
	c.TplName = "imageAuthor.html"
}

// UserSFZAuthor 身份证认证页面
func (c *PageController) UserSFZAuthor() {
	c.TplName = "userSFZAuthor.html"
}

// Agreement 跳转到 用户协议同意页面
func (c *PageController) Agreement() {
	c.TplName = "agreement.html"
}
